import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.swing.JPanel;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.jdesktop.application.Application;
import javax.swing.SwingUtilities;

import javax.swing.*;
import org.jvnet.substance.*;
import org.jvnet.substance.button.StandardButtonShaper;
import org.jvnet.substance.theme.*;
import org.jvnet.substance.watermark.*;
import org.jvnet.substance.theme.transform.*;
import org.jvnet.substance.utils.SubstanceConstants;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class frmListado extends javax.swing.JFrame {
	private JPanel pnlListado;
	private JTabbedPane tabListado;
	private JTable tblCedula;
	private JTable tblNotaFinal;
	private JTable tblAprobado;
	private JTable tblListadoEstudiante;
	
	private JLabel lblContarMatricula;
	private JLabel lblMatricula;
	private JLabel lblMostrarRendimiento;
	private JLabel lblRendimiento;
	private JLabel lblNota;
	private JTable tblReprobado;
	private JButton btnCalcularPromedio;
	private JLabel lblPromedioNotas;
	private JLabel lblProfesorCompleto;
	private JLabel lblProfesor;
	private JLabel lblNumeroSeccion;
	private JLabel lblSeccion;
	private Seccion seccion = new Seccion();
	private String nombreColumnas;
	private Object alumnosCedula;

	
	
	public frmListado() {
		super("Listado");
		initGUI();
		this.setResizable(false);
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				pnlListado = new JPanel();
				getContentPane().add(pnlListado, BorderLayout.CENTER);
				pnlListado.setBackground(new java.awt.Color(255, 255, 255));
				pnlListado.setLayout(null);
				pnlListado.setPreferredSize(new java.awt.Dimension(910, 409));
				{
					tabListado = new JTabbedPane();
					pnlListado.add(tabListado);
					tabListado.setBounds(12, 52, 633, 318);
					
					{
						TableModel tblListadoEstudianteModel = 
							new DefaultTableModel(
									new Object[frmMenuPrincipal.seccion.getVectorPrincipal().size()][3],
									new String[] { "CÉDULA", "NOMBRE", "APELLIDO" });
						tblListadoEstudiante = new JTable();
						tabListado.addTab("Alumnos por Cédula", null, tblListadoEstudiante, null);
						for(int i = 0; i < frmMenuPrincipal.seccion.getVectorPrincipal().size(); i++){
							tblListadoEstudianteModel.setValueAt(frmMenuPrincipal.seccion.getVectorPrincipal().elementAt(i).getCI(), i, 0);
							tblListadoEstudianteModel.setValueAt(frmMenuPrincipal.seccion.getVectorPrincipal().elementAt(i).getNom(), i, 1);
							tblListadoEstudianteModel.setValueAt(frmMenuPrincipal.seccion.getVectorPrincipal().elementAt(i).getApe(), i, 2);
						}
						
						tblListadoEstudiante.setModel(tblListadoEstudianteModel);
						tblListadoEstudiante.setShowGrid(true);
						tblListadoEstudiante.setShowHorizontalLines(true);
						/*tblListadoEstudiante.setPreferredScrollableViewportSize(new Dimension(200,100));
						JScrollPane jscrollpane =new JScrollPane(tblListadoEstudiante);
						jscrollpane.setPreferredSize(new java.awt.Dimension(163, 142));*/
						tblListadoEstudiante.setBounds(694, 331, 155, 74);
					}
					{
						TableModel tblNotaFinalModel = 
							new DefaultTableModel(
									new Object[frmMenuPrincipal.seccion.getVectorNotaFinal().size()][4],
									new String[] { "CÉDULA", "NOMBRE", "APELLIDO", "NOTA FINAL" });
						tblNotaFinal = new JTable();
						tabListado.addTab("Alumnos por NotaFinal", null, tblNotaFinal, null);
						for(int i = 0; i < frmMenuPrincipal.seccion.getVectorNotaFinal().size(); i++){
							tblNotaFinalModel.setValueAt(frmMenuPrincipal.seccion.getVectorNotaFinal().elementAt(i).getCI(), i, 0);
							tblNotaFinalModel.setValueAt(frmMenuPrincipal.seccion.getVectorNotaFinal().elementAt(i).getNom(), i, 1);
							tblNotaFinalModel.setValueAt(frmMenuPrincipal.seccion.getVectorNotaFinal().elementAt(i).getApe(), i, 2);
							tblNotaFinalModel.setValueAt(frmMenuPrincipal.seccion.getVectorNotaFinal().elementAt(i).getNotaFinal(), i, 3);
						}
						tblNotaFinal.setModel(tblNotaFinalModel);
						tblNotaFinal.setShowGrid(true);
						tblNotaFinal.setShowHorizontalLines(true);
						tblNotaFinal.setBounds(316, 193, 628, 261);
					}
					{
						TableModel tblAprobadoModel = 
							new DefaultTableModel(
									new Object[frmMenuPrincipal.seccion.getVectorAprobados().size()][4],
									new String[] { "CÉDULA", "NOMBRE", "APELLIDO", "NOTA FINAL" });
						tblAprobado = new JTable();
						tabListado.addTab("Alumnos Aprobado", null, tblAprobado, null);
						for(int i = 0; i < frmMenuPrincipal.seccion.getVectorAprobados().size(); i++){
							tblAprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorAprobados().elementAt(i).getCI(), i, 0);
							tblAprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorAprobados().elementAt(i).getNom(), i, 1);
							tblAprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorAprobados().elementAt(i).getApe(), i, 2);
							tblAprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorAprobados().elementAt(i).getNotaFinal(), i, 3);
						}
						tblAprobado.setModel(tblAprobadoModel);
						tblAprobado.setShowGrid(true);
						tblAprobado.setShowHorizontalLines(true);
						tblAprobado.setBounds(51, 193, 628, 291);
					}
					{
						TableModel tblReprobadoModel = 
							new DefaultTableModel(
									new Object[frmMenuPrincipal.seccion.getVectorReprobados().size()][4],
									new String[] { "CÉDULA", "NOMBRE", "APELLIDO", "NOTA FINAL" });
						tblReprobado = new JTable();
						tabListado.addTab("Alumnos Reprobados", null, tblReprobado, null);
						for(int i = 0; i < frmMenuPrincipal.seccion.getVectorReprobados().size(); i++){
							tblReprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorReprobados().elementAt(i).getCI(), i, 0);
							tblReprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorReprobados().elementAt(i).getNom(), i, 1);
							tblReprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorReprobados().elementAt(i).getApe(), i, 2);
							tblReprobadoModel.setValueAt(frmMenuPrincipal.seccion.getVectorReprobados().elementAt(i).getNotaFinal(), i, 3);
						}
						tblReprobado.setModel(tblReprobadoModel);
						tblReprobado.setShowGrid(true);
						tblReprobado.setShowHorizontalLines(true);
						tblReprobado.setBounds(12, 124, 627, 291);
					}
				}
				{
					lblSeccion = new JLabel();
					pnlListado.add(lblSeccion);
					lblSeccion.setText("Sección: ");
					lblSeccion.setForeground(new java.awt.Color(0, 0, 0));
					lblSeccion.setFont(new Font("Bitstream Charter", java.awt.Font.BOLD, 15));
					lblSeccion.setBounds(18, 26, 72, 15);
				}
				{
					lblNumeroSeccion = new JLabel();
					pnlListado.add(lblNumeroSeccion);
					lblNumeroSeccion.setBounds(81, 22, 61, 20);
					
				}
				{
					lblProfesor = new JLabel();
					pnlListado.add(lblProfesor);
					lblProfesor.setText("Profesor: ");
					lblProfesor.setForeground(new java.awt.Color(0, 0, 0));
					lblProfesor.setFont(new Font("Bitstream Charter", java.awt.Font.BOLD, 15));
					lblProfesor.setBounds(168, 26, 82, 15);
				}
				{
					lblProfesorCompleto = new JLabel();
					pnlListado.add(lblProfesorCompleto);
					lblProfesorCompleto.setText(" ");
					lblProfesorCompleto.setBounds(252, 22, 387, 20);
					
				}
				{
					Icon calcularpromedio = new ImageIcon(getClass().getResource("src/resources/Imagenes/calcularpromedio30x30.png"));
					btnCalcularPromedio = new JButton("Calcular Promedio", calcularpromedio);
					btnCalcularPromedio.putClientProperty(SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, new StandardButtonShaper());
					btnCalcularPromedio.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, SubstanceConstants.Side.LEFT);
					pnlListado.add(btnCalcularPromedio);
					btnCalcularPromedio.setBounds(657, 177, 217, 47);
					btnCalcularPromedio.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							frmMenuPrincipal.seccion.calcularPromedio();
							frmListado.this.lblNota.setText(""+frmMenuPrincipal.seccion.getPromedio()+" Puntos");
							frmListado.this.lblMostrarRendimiento.setText(""+frmMenuPrincipal.seccion.getRendimiento()+" %");
							
							frmMensaje frmEvaluacionAplicada = new frmMensaje();
							frmEvaluacionAplicada.getLblMensaje().setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
							frmEvaluacionAplicada.getLblMensaje().setFont(new Font("Courier 10 Pitch", java.awt.Font.BOLD, 18));
							frmEvaluacionAplicada.getLblMensaje().setText("Operación Exitosa");
							
							frmEvaluacionAplicada.setDefaultLookAndFeelDecorated(true);
							SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.RavenGraphiteGlassSkin");
							SubstanceLookAndFeel.setCurrentTheme("org.jvnet.substance.theme.SubstanceAquaTheme");
							SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");
							frmEvaluacionAplicada.setLocationRelativeTo(null);
						    frmEvaluacionAplicada.setVisible(true);
						    
							//System.out.println("btnCalcularPromedio.actionPerformed, event="+evt);
							//TODO add your code for btnCalcularPromedio.actionPerformed
						}
					});
				}
				
				{
					lblPromedioNotas = new JLabel();
					pnlListado.add(lblPromedioNotas);
					lblPromedioNotas.setText("Promedio de Notas: ");
					lblPromedioNotas.setForeground(new java.awt.Color(0, 0, 0));
					lblPromedioNotas.setFont(new Font("Bitstream Charter", java.awt.Font.BOLD, 15));
					lblPromedioNotas.setBounds(24, 401, 174, 31);
				}
				{
					lblNota = new JLabel();
					pnlListado.add(lblNota);
					lblNota.setBounds(176, 405, 85, 23);
				}
				{
					lblRendimiento = new JLabel();
					pnlListado.add(lblRendimiento);
					lblRendimiento.setText("Rendimiento: ");
					lblRendimiento.setForeground(new java.awt.Color(0, 0, 0));
					lblRendimiento.setFont(new Font("Bitstream Charter", java.awt.Font.BOLD, 15));
					lblRendimiento.setBounds(363, 407, 171, 25);
				}
				{
					lblMostrarRendimiento = new JLabel();
					pnlListado.add(lblMostrarRendimiento);
					lblMostrarRendimiento.setBounds(515, 407, 99, 20);
				}
				{
					lblMatricula = new JLabel();
					pnlListado.add(lblMatricula);
					lblMatricula.setText("Matricula: ");
					lblMatricula.setForeground(new java.awt.Color(0, 0, 0));
					lblMatricula.setFont(new Font("Bitstream Charter", java.awt.Font.BOLD, 15));
					lblMatricula.setBounds(645, 26, 91, 15);
				}
				{
					lblContarMatricula = new JLabel();
					pnlListado.add(lblContarMatricula);
					lblContarMatricula.setBounds(737, 23, 112, 17);
				}
				

			}
			pack();
			this.setSize(896, 489);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public JLabel getLblProfesorCompleto() {
		return lblProfesorCompleto;
	}

	public void setLblProfesorCompleto(JLabel lblProfesorCompleto) {
		this.lblProfesorCompleto = lblProfesorCompleto;
	}

	public JLabel getLblNumeroSeccion() {
		return lblNumeroSeccion;
	}

	public void setLblNumeroSeccion(JLabel lblNumeroSeccion) {
		this.lblNumeroSeccion = lblNumeroSeccion;
	}

	public Seccion getSeccion() {
		return seccion;
	}

	public void setSeccion(Seccion seccion) {
		this.seccion = seccion;
	}

	

	public JTable getTblCedula() {
		return tblCedula;
	}

	public void setTblCedula(JTable tblCedula) {
		this.tblCedula = tblCedula;
	}

	public void setTblCedula(DefaultTableModel tableOrdenCedula) {
		// TODO Auto-generated method stub
		
	}


	public JLabel getLblContarMatricula() {
		return lblContarMatricula;
	}

	public void setLblContarMatricula(JLabel lblContarMatricula) {
		this.lblContarMatricula = lblContarMatricula;
	}
	

}
